package com.biu.zone.common.utils;

import android.widget.ImageView;

import com.biu.zone.application.MyApp;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;

import androidx.annotation.DrawableRes;

/**
 * Created by zkt on 19/01/30.
 * Description:
 */
public class ImageLoader {

    private static RequestOptions requestOptions;
    private static RequestOptions requestOptions1;

    static {
        requestOptions = new RequestOptions()
//                .placeholder(R.drawable.img_default)
                //.circleCrop()
                .diskCacheStrategy(DiskCacheStrategy.ALL);

        requestOptions1 = new RequestOptions()
//                .placeholder(R.drawable.img_doctor)
                //.circleCrop()
                .diskCacheStrategy(DiskCacheStrategy.ALL);
    }

    public static void showHead(ImageView imageView, @DrawableRes int resId) {
        Glide.with(MyApp.getCtx())
                .load(resId)
                .apply(requestOptions)
                .into(imageView);
    }

    public static void showHead(ImageView imageView, String url) {
        Glide.with(MyApp.getCtx())
                .load(url)
                .apply(requestOptions1)
                .into(imageView);
    }

    public static void show(ImageView imageView, String url) {
        Glide.with(MyApp.getCtx())
                .load(url)
                .apply(requestOptions1)
                .into(imageView);
    }
}
